<meta charset="utf-8" />
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li><i class="ace-icon fa fa-home home-icon"></i>
            <a href="index">主数据管理</a>
        </li>
        <li><span>物料组管理</span></li>
    </ul>
</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="clearfix"></div>
            <div class="table-header">物料组管理</div>
            <div>
                <div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
                    <div class="row">
                        <div class="widget">
                            <div class="widget-main">
                                <form class="form-inline" id="selefrom" action="wlzgl/sele" method="post">
                                    <!--<input type="search" style="width:120px;height:30px " ; class="form-control input-sm" placeholder="输入查询内容" aria-controls="dynamic-table" name="selevalue" id="hhh1">-->
                                    <button id="selectfromsb" style="height:30px" class="btn btn-info btn-sm">新增</button>
                                    <button id="selectfromsb" style="height:30px" class="btn btn-info btn-sm">编辑</button>
                                    <button id="selectfromcz" style="height:30px" class="btn btn-info btn-sm">删除</button>
                                </form>
                            </div>
                        </div>
                    </div>
                    <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" id="dynamic-table" role="grid" aria-describedby="dynamic-table_info">
                        <thead>
                        <tr role="row">
                            <th class="center" style="width:9px; "><label> <input type="checkbox" class="ace"/><span class="lbl"></span></label></th>
                            <th>物料组编码</th>
                            <th>物料组名称</th>
                            <th>班组人数</th>
                            <th>采购负责人</th>
                            <th>质量负责人</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody id="banzupage">
                        </tbody>
                    </table>
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class=" pull-left">
                                <label>显示<select name="dynamic-table_length"
                                                 aria-controls="dynamic-table" class="form-control input-sm"
                                                 id="sel"><option value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="50">50</option>
                                    <option value="100">100</option>
                                </select> 条记录</label>
                            </div>
                            <div class="dataTables_paginate paging_simple_numbers ">
                                <ul class="pagination" id="dynamic-table_paginate111">
                                </ul>
                                <div class="dataTables_paginate paging_simple_numbers">
                                    <div class="laypage_main laypageskin_molv" id="laypage_3">
                                        <span class="laypage_curr" style="background-color:#2283C5">1</span>
										<span class="laypage_total"><label>到第</label>
											<input max="1"
                                                   min="1" class="laypage_skip" type="number"><label>页</label>
											<button type="button" class="laypage_btn">确定<tton>
										</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 更改每页显示数据的数目 -->
<script type="text/javascript">
    var sel = document.getElementById("sel");
    sel.onchange = function() {
        /* alert(sel.options[sel.selectedIndex].value); */
        $.post("wlzgl/gghs", {
            "pagen": sel.options[sel.selectedIndex].value
        }, function(data) {
            pagedemo(1);
        });
    }
    //
    pagedemo(1);
    function pagedemo(n) {
        $.post("wlzgl/pagedemo", {
            "pageNumber": n,
            "pch": $("#pch").val()
        }, function(data) {
            pack(data.list); //调用上面pack()方法，填充表格数据

            if(data.totalPage == 1) {
                $("#dynamic-table_paginate111").addClass("hide");
                $("#laypage_3").removeClass("hide");
            } else {
                $("#laypage_3").addClass("hide");
                $("#dynamic-table_paginate111").removeClass("hide");
                laypage({
                    cont: $('#dynamic-table_paginate111'), //容器。值支持id名、原生dom对象，jquery对象,
                    pages: data.totalPage, //总页数
                    skip: true, //是否开启跳页
                    skin: '#2283C5', //保持ace中间的样式
                    first: 1,
                    last: data.totalPage, //总页数，将尾页显示为总页数
                    curr: data.pageNumber, //当前页
                    groups: 5, //连续显示分页数
                    jump: function(obj, first) {
                        if(!first) { //一定要加此判断，否则初始时会无限刷新
                            pagedemo(obj.curr);
                        }
                    }
                });
            }

        });
    }

    function pack(data) { //填充数据
        var dataStr = "";
        $.each(data, function(i, v) {
            dataStr += packlist(v);
        });
        $("#banzupage").html(dataStr);
    }

    function packlist(v) {
        var dataStr = "";
        dataStr += '<tr>';
        dataStr += '<td>' + v.bzbm + '</td>';
        dataStr += '<td>' + v.bzmc + '</td>';
        dataStr += '<td>' + v.bzrs + '</td>';
        dataStr += '<td>' + v.cpwlbm + '</td>';
        dataStr += '<td>' + v.cpwlmc + '</td>';
        dataStr += '</tr>';
        return dataStr;
    };

    /* 撤销查询 */
    $("#selectfromcz").click(function() {
        document.getElementById("hhh1").value = "";
        $.post("wlzgl/sele", $("#selefrom").serialize(), function(data) {
            pagedemo(1);
        })
        return false;
    });
    /* 查询 */
    $("#selectfromsb").click(function() {
        $.post("wlzgl/sele", $("#selefrom").serialize(), function(data) {
            pagedemo(1);
        })
        return false;
    }
    });

    //错误提示(传入错误信息)
    function errorMsg(errorInfo) {
        layer.confirm(errorInfo, {
            btn: ['确定']
            //按钮
        }, function(index) {
            layer.close(index);
        });
    }
</script>